DEFINITION MODULE Objects;

(* (C) Copyright 1992 Fitted Software Tools. All rights reserved. *)

(*
    Please read the chapter "Classes" in the user documentation
    for information about this module.
*)

FROM SYSTEM IMPORT ADDRESS;

TYPE
    Class = POINTER TO ClassPtr;
    ClassPtr = POINTER TO ClassHeader;
    ClassHeader = RECORD
        parent      :Class;
        size        :CARDINAL;
        filler      :CARDINAL;
        InitProc    :PROCEDURE( ADDRESS );
        DestroyProc :PROCEDURE( ADDRESS );
    END;

    ObjPtr = POINTER TO RECORD
        class :ClassPtr
        (* data *)
    END;


PROCEDURE ALLOCATEOBJECT( VAR op :ObjPtr; cp :ClassPtr );
(*
    Allocates storage (calling Storage.ALLOCATE) for an object
    of class cp, places the object's address (handle) in op
    and invokes the INIT methods defined for class cp.
*)

PROCEDURE DEALLOCATEOBJECT( VAR op :ObjPtr );
(*
    Invokes the DESTROY methods in op's class and deallocates the
    storage used by op. op is set to NIL.
*)

PROCEDURE MEMBEROBJECT( cp :ClassPtr; class :ClassPtr ) :BOOLEAN;
(*
    TRUE if cp is of class class or one of its descendants.
*)

END Objects.
